//
//  CYUser.m
//  CreditAddressBook
//
//  Created by Lee on 15/4/28.
//  Copyright (c) 2015年 Lee. All rights reserved.
//

#import "CYUser.h"
#import "MJExtension.h"
#import "CYURL.h"

@implementation CYUser

MJCodingImplementation

+ (NSDictionary *)replacedKeyFromPropertyName {
    return @{@"userId": @"id"};
}

/**
 *  这个数组中的属性名将会被忽略：不进行字典和模型的转换
 */
+ (NSArray *)ignoredPropertyNames {
    return @[@"isShowExamineBtn", @"certificateExamineStatusText"];
}
/**
 *  这个数组中的属性名将会被忽略：不进行归档
 */
+ (NSArray *)ignoredCodingPropertyNames {
    return @[@"isShowExamineBtn", @"certificateExamineStatusText"];
}

- (BOOL)isShowExamineBtn {
    if (_certificateExamineStatus && ![_certificateExamineStatus isKindOfClass:[NSNull class]]) {
        if ([_certificateExamineStatus longLongValue] == 0) {
            return YES;
        }else if ([_certificateExamineStatus longLongValue] == 1) {
            return NO;
        }else if ([_certificateExamineStatus longLongValue] == -1) {
            return YES;
        }else if ([_certificateExamineStatus longLongValue] == 2) {
            return NO;
        }
    }
        return NO;
}

- (NSString *)certificateExamineStatusText {
if (_certificateExamineStatus && ![_certificateExamineStatus isKindOfClass:[NSNull class]]){
    if ([_certificateExamineStatus longLongValue] == 0) {
        return @"待提交";
    }else if ([_certificateExamineStatus longLongValue] == 1) {
        return @"审核已提交";
    }else if ([_certificateExamineStatus longLongValue] == -1) {
        return @"审核不通过";
    }else if ([_certificateExamineStatus longLongValue] == 2) {
        return @"审核通过";
      }
    }
    return @"待提交";
}


//- (NSString *)userType {
//    if ([_userType longLongValue] == 0) {
//        return @"个人";
//    }else if ([_userType longLongValue] == 1) {
//        return @"企业";
//    }else if ([_userType longLongValue] == 2) {
//        return @"百翼财富人员";
//    }else if ([_userType longLongValue] == 3) {
//        return @"管理员";
//    }
//    return _userType;
//}

//- (NSString *)examineStatus {
//    if ([_examineStatus longLongValue] == 0) {
//        return @"待审核";
//    }else if ([_examineStatus longLongValue] == 1) {
//        return @"审核已提交";
//    }else if ([_examineStatus longLongValue] == -1) {
//        return @"审核不通过";
//    }else if ([_examineStatus longLongValue] == 2) {
//        return @"审核通过";
//    }
//    return _examineStatus;
//}

/**
 *  从文件中解析对象的时候调
 */
//- (id)initWithCoder:(NSCoder *)decoder
//{
//    if (self = [super init]) {
//        self.certificateNo = [decoder decodeObjectForKey:@"certificateNo"];
//        self.certificateNoAddress = [decoder decodeObjectForKey:@"certificateNoAddress"];
//        self.certificateNoFAddress = [decoder decodeObjectForKey:@"certificateNoFAddress"];
//        self.certificateNoZAddress = [decoder decodeObjectForKey:@"certificateNoZAddress"];
//        self.companyInfo = [decoder decodeObjectForKey:@"companyInfo"];
//        self.funcGroup = [decoder decodeObjectForKey:@"funcGroup"];
//        self.headPic = [decoder decodeObjectForKey:@"headPic"];
//        self.userId = [decoder decodeObjectForKey:@"userId"];
//        self.name = [decoder decodeObjectForKey:@"name"];
//        self.nickName = [decoder decodeObjectForKey:@"nickName"];
//        self.phone = [decoder decodeObjectForKey:@"phone"];
//        self.searchTimes = [decoder decodeObjectForKey:@"searchTimes"];
//        self.status = [decoder decodeObjectForKey:@"status"];
//        self.examineStatus = [decoder decodeObjectForKey:@"examineStatus"];
//        self.userName = [decoder decodeObjectForKey:@"userName"];
//        self.userPassword = [decoder decodeObjectForKey:@"userPassword"];
//        self.userType = [decoder decodeObjectForKey:@"userType"];
//    }
//    return self;
//}
//
///**
// *  将对象写入文件的时候调用
// */
//- (void)encodeWithCoder:(NSCoder *)encoder
//{
//    [encoder encodeObject:self.certificateNo forKey:@"certificateNo"];
//    [encoder encodeObject:self.certificateNoAddress forKey:@"certificateNoAddress"];
//    [encoder encodeObject:self.certificateNoFAddress forKey:@"certificateNoFAddress"];
//    [encoder encodeObject:self.certificateNoZAddress forKey:@"certificateNoZAddress"];
//    [encoder encodeObject:self.companyInfo forKey:@"companyInfo"];
//    [encoder encodeObject:self.funcGroup forKey:@"funcGroup"];
//    [encoder encodeObject:self.headPic forKey:@"headPic"];
//    [encoder encodeObject:self.userId forKey:@"userId"];
//    [encoder encodeObject:self.name forKey:@"name"];
//    [encoder encodeObject:self.nickName forKey:@"nickName"];
//    [encoder encodeObject:self.phone forKey:@"phone"];
//    [encoder encodeObject:self.searchTimes forKey:@"searchTimes"];
//    [encoder encodeObject:self.status forKey:@"status"];
//    [encoder encodeObject:_examineStatus forKey:@"examineStatus"];
//    [encoder encodeObject:self.userName forKey:@"userName"];
//    [encoder encodeObject:self.userPassword forKey:@"userPassword"];
//    [encoder encodeObject:_userType forKey:@"userType"];
//}

//- (NSString *)headPic {
//    NSRange range = [_headPic rangeOfString:CYSTATICPATHBASIC];
//    if (_headPic && ![_headPic isEqualToString:@""] && range.location == NSNotFound) {
//        return [CYSTATICPATHBASIC stringByAppendingString:_headPic];
//    }
//    return _headPic;
//}
//
//- (NSString *)certificateNoAddress {
//    NSRange range = [_headPic rangeOfString:CYSTATICPATHBASIC];
//    if (_certificateNoAddress && ![_certificateNoAddress isEqualToString:@""] && range.location == NSNotFound) {
//        return [CYSTATICPATHBASIC stringByAppendingString:_certificateNoAddress];
//    }
//    return _certificateNoAddress;
//}
//
//- (NSString *)certificateNoFAddress {
//    NSRange range = [_headPic rangeOfString:CYSTATICPATHBASIC];
//    if (_certificateNoFAddress && ![_certificateNoFAddress isEqualToString:@""] && range.location == NSNotFound) {
//        return [CYSTATICPATHBASIC stringByAppendingString:_certificateNoFAddress];
//    }
//    return _certificateNoFAddress;
//}
//
//- (NSString *)certificateNoZAddress {
//    NSRange range = [_headPic rangeOfString:CYSTATICPATHBASIC];
//    if (_certificateNoZAddress && ![_certificateNoZAddress isEqualToString:@""] && range.location == NSNotFound) {
//        return [CYSTATICPATHBASIC stringByAppendingString:_certificateNoZAddress];
//    }
//    return _certificateNoZAddress;
//}

//- (NSString *)companyInfo {
//    if ([_companyInfo isKindOfClass:[NSNull class]]) {
//        return nil;
//    }
//    return _companyInfo;
//}

@end
